Skip to content

ADPS-1406 Implement multiple servers in database connection Ranger#54

Open
slavachy wants to merge 4 commits into
develop/2.2.0/2.6.0.4from
feature/ADPS-1406
Open

ADPS-1406 Implement multiple servers in database connection Ranger#54
slavachy wants to merge 4 commits into
develop/2.2.0/2.6.0.4from
feature/ADPS-1406

Conversation

@slavachy

Copy link
Copy Markdown
Collaborator

No description provided.

Comment thread kms/scripts/install.properties Outdated
#db_host=host:port:SID # for DB_FLAVOR=ORACLE #for SID example: db_host=localhost:1521:ORCL
#db_host=host:port/ServiceName # for DB_FLAVOR=ORACLE #for Service example: db_host=localhost:1521/XE
#db_host=host:port:GL # for DB_FLAVOR=ORACLE #for TNSNAME example: db_host=localhost:1521:GL
#_host=host:port/ServiceName # for DB_FLAVOR=ORACLE #for Service example: db_host=localhost:1521/XE

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

change "_host" to "db_host"

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thx, i copied it bad,fixed

<include>setup.sh</include>
<include>setup_authentication.sh</include>
<include>set_globals.sh</include>
<include>pg_jdbc_util.py</include>

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inconsistent build. In kms.xml we have fileMode=544, but not there

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

both packages already use 544. In admin-web.xml, pg_jdbc_util.py inherits <fileMode>544</fileMode> from the enclosing <fileSet> (same as db_setup.py and dba_script.py)

in kms.xml it is set explicitly to 544 as a standalone <file> entry

Comment thread kms/scripts/dba_script.py
from os.path import basename
from subprocess import Popen,PIPE
from datetime import date
from pg_jdbc_util import build_pg_query_params

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only build_pg_query_params is imported; the jisql JDBC URL is built using raw self.host directly, bypassing build_pg_host_segment. This function is actually used only in ranger_install.py. Either drop the unnecessary import from the 4 files where it's not used, or hook build_pg_host_segment into the jisql URL construction there too.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

only build_pg_query_params is imported in these 4 files- intentionally
In db_setup.py/dba_script.py the host field already contains the full host:port string (stored as-is in __init__), so build_pg_host_segment would add no value:

it would just hit the if ':' in host: return host branch and return unchanged. build_pg_host_segment is needed only in ranger_install.py where host and port arrive as separate config variables and must be joined

from subprocess import Popen,PIPE

try:
sys.path.insert(0, os.getenv('RANGER_ADMIN_HOME', os.path.join(os.path.dirname(os.path.abspath(__file__)), '..', '..', 'scripts')))

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

try/except ImportError fallback block duplicates the logic of build_pg_host_segment and build_pg_query_params

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fallback is intentional and follows the same pattern already used in this file for StringIO/ConfigParser
ranger_install.py lives in src/bin/, while pg_jdbc_util.py is in scripts/- they can be on different paths depending on the deployment layout
without the fallback, an ImportError would abort entire script for all DB flavors (MySQL, Oracle, MSSQL), not just Postgres
inline copies are kept minimal on purpose,full implementation is in pg_jdbc_util.py

updatePropertyToFilePy(propertyName ,newPropertyValue ,to_file_ranger)

elif RANGER_DB_FLAVOR == "POSTGRES":
pg_admin_host = build_pg_host_segment(MYSQL_HOST, RANGER_ADMIN_DB_PORT)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MYSQL_HOST variable name in PG context is confusing

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MYSQL_HOST is a legacy variable used throughout the file for all DB
It was there before this PR
idk if this edit makes sense in this PR

@slavachy slavachy requested a review from asanisimov June 29, 2026 14:40
@slavachy slavachy marked this pull request as ready for review June 30, 2026 11:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants